package com.pzh.mall.web.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.pzh.mall.service.IPayService;
import com.pzh.sys.controller.BaseController;
import cn.hehuoren.core.utils.response.HttpResponseBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping("/api/pay")
public class PayController extends BaseController{
    @Reference
    private IPayService payService;

    @PostMapping("orderPay")
    public HttpResponseBody orderPay(Integer orderId,String payCode, BigDecimal payAmount){
        String payResult = payService.doPay(orderId,payCode,payAmount,getSessionUserId());
        if("success".equals(payResult)){
            return HttpResponseBody.successResponse("支付成功");
        }else{
            return HttpResponseBody.failResponse(payResult);
        }
    }
}
